//
//  HTHomeTitleButtonView.swift
//  mySinaBlog
//
//  Created by whtapple on 3/26/16.
//  Copyright © 2016 whtapple. All rights reserved.
//

import UIKit

class HTHomeTitleButtonView: UIButton {
//    var title: UILabel?
//    var iconView: UIImageView?
//    class func homeTitleButton() -> HTHomeTitleButtonView {
//        let btn = HTHomeTitleButtonView()
//        let title = UILabel()
//        title.text = "myloveQian"
//        title.font = UIFont.systemFontOfSize(14)
//        title.textColor = UIColor.redColor()
//        title.sizeToFit()
//       
//        let iconView = UIImageView(image: UIImage(named: "navigationbar_arrow_down")
//)
//        iconView.sizeToFit()
//        title = title
//        btn.addSubview(title)
//         title.addSubview(iconView)
//        return btn
//    
//    }
    
// 便利构造函数，设置 title 和 image
    convenience init(title: String,image: String){
        self.init()
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        self.titleLabel?.font = UIFont.systemFontOfSize(16)
        setImage(UIImage(named: image), forState: UIControlState.Normal)
//        self.backgroundColor = UIColor.blueColor()
        self.sizeToFit()
    }
    //改变两个的位置
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLabel!.frame.origin.x = 0
        imageView?.frame.origin.x = titleLabel!.frame.size.width + 3
    }
}
